<template>
  <div class="wholesale-statistics">
    <!-- 页面标题 -->
    <div class="page-header">
      <h2>批发统计分析</h2>
      <p>批发业务数据统计与分析</p>
    </div>

    <!-- 统计概览 -->
    <div class="statistics-overview">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-item">
              <div class="stat-icon sales">
                <el-icon><TrendCharts /></el-icon>
              </div>
              <div class="stat-content">
                <div class="stat-value">¥{{ formatNumber(overviewData.totalSales) }}</div>
                <div class="stat-label">总销售额</div>
                <div class="stat-change positive">+12.5%</div>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-item">
              <div class="stat-icon orders">
                <el-icon><Document /></el-icon>
              </div>
              <div class="stat-content">
                <div class="stat-value">{{ overviewData.totalOrders }}</div>
                <div class="stat-label">订单数量</div>
                <div class="stat-change positive">+8.3%</div>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-item">
              <div class="stat-icon customers">
                <el-icon><User /></el-icon>
              </div>
              <div class="stat-content">
                <div class="stat-value">{{ overviewData.totalCustomers }}</div>
                <div class="stat-label">客户数量</div>
                <div class="stat-change positive">+15.2%</div>
              </div>
            </div>
          </el-card>
        </el-col>
        <el-col :span="6">
          <el-card class="stat-card">
            <div class="stat-item">
              <div class="stat-icon profit">
                <el-icon><Money /></el-icon>
              </div>
              <div class="stat-content">
                <div class="stat-value">¥{{ formatNumber(overviewData.totalProfit) }}</div>
                <div class="stat-label">总利润</div>
                <div class="stat-change positive">+18.7%</div>
              </div>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>

    <!-- 筛选条件 -->
    <el-card class="filter-section">
      <el-form :model="filterForm" inline>
        <el-form-item label="时间范围">
          <el-date-picker
            v-model="filterForm.dateRange"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            format="YYYY-MM-DD"
            value-format="YYYY-MM-DD"
            @change="handleDateChange"
          />
        </el-form-item>
        <el-form-item label="客户等级">
          <el-select v-model="filterForm.customerLevel" placeholder="请选择客户等级" clearable>
            <el-option label="全部" value="" />
            <el-option label="VIP" value="VIP" />
            <el-option label="一级" value="一级" />
            <el-option label="二级" value="二级" />
            <el-option label="三级" value="三级" />
            <el-option label="普通" value="普通" />
          </el-select>
        </el-form-item>
        <el-form-item label="商品分类">
          <el-select v-model="filterForm.productCategory" placeholder="请选择商品分类" clearable>
            <el-option label="全部" value="" />
            <el-option label="电子产品" value="电子产品" />
            <el-option label="服装鞋帽" value="服装鞋帽" />
            <el-option label="食品饮料" value="食品饮料" />
            <el-option label="家居用品" value="家居用品" />
            <el-option label="美妆护肤" value="美妆护肤" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleSearch" :icon="Search">查询</el-button>
          <el-button @click="handleReset" :icon="Refresh">重置</el-button>
          <el-button type="success" @click="handleExport" :icon="Download">导出报表</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <!-- 图表区域 -->
    <el-row :gutter="20" class="charts-section">
      <!-- 销售趋势图 -->
      <el-col :span="12">
        <el-card header="销售趋势分析">
          <div ref="salesTrendChart" class="chart-container"></div>
        </el-card>
      </el-col>
      
      <!-- 客户分布图 -->
      <el-col :span="12">
        <el-card header="客户等级分布">
          <div ref="customerDistributionChart" class="chart-container"></div>
        </el-card>
      </el-col>
    </el-row>

    <el-row :gutter="20" class="charts-section">
      <!-- 商品销量排行 -->
      <el-col :span="12">
        <el-card header="商品销量排行">
          <div ref="productRankingChart" class="chart-container"></div>
        </el-card>
      </el-col>
      
      <!-- 利润分析 -->
      <el-col :span="12">
        <el-card header="利润分析">
          <div ref="profitAnalysisChart" class="chart-container"></div>
        </el-card>
      </el-col>
    </el-row>

    <!-- 数据表格 -->
    <el-card class="table-section" header="详细数据">
      <el-tabs v-model="activeTab" @tab-change="handleTabChange">
        <!-- 销售明细 -->
        <el-tab-pane label="销售明细" name="sales">
          <el-table :data="salesDetailData" border style="width: 100%">
            <el-table-column prop="date" label="日期" width="120" />
            <el-table-column prop="customerName" label="客户名称" width="150" />
            <el-table-column prop="customerLevel" label="客户等级" width="100">
              <template #default="{ row }">
                <el-tag :type="getCustomerLevelType(row.customerLevel)">{{ row.customerLevel }}</el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="productName" label="商品名称" width="200" />
            <el-table-column prop="quantity" label="数量" width="100" align="right" />
            <el-table-column prop="unitPrice" label="单价" width="120" align="right">
              <template #default="{ row }">
                ¥{{ row.unitPrice.toFixed(2) }}
              </template>
            </el-table-column>
            <el-table-column prop="totalAmount" label="总金额" width="120" align="right">
              <template #default="{ row }">
                ¥{{ row.totalAmount.toFixed(2) }}
              </template>
            </el-table-column>
            <el-table-column prop="profit" label="利润" width="120" align="right">
              <template #default="{ row }">
                <span :class="{ 'profit-positive': row.profit > 0, 'profit-negative': row.profit < 0 }">
                  ¥{{ row.profit.toFixed(2) }}
                </span>
              </template>
            </el-table-column>
            <el-table-column prop="profitRate" label="利润率" width="100" align="right">
              <template #default="{ row }">
                <span :class="{ 'profit-positive': row.profitRate > 0, 'profit-negative': row.profitRate < 0 }">
                  {{ (row.profitRate * 100).toFixed(1) }}%
                </span>
              </template>
            </el-table-column>
          </el-table>
          <div class="pagination-wrapper">
            <el-pagination
              v-model:current-page="salesPagination.currentPage"
              v-model:page-size="salesPagination.pageSize"
              :page-sizes="[10, 20, 50, 100]"
              :total="salesPagination.total"
              layout="total, sizes, prev, pager, next, jumper"
              @size-change="handleSalesPageSizeChange"
              @current-change="handleSalesPageChange"
            />
          </div>
        </el-tab-pane>
        
        <!-- 客户分析 -->
        <el-tab-pane label="客户分析" name="customers">
          <el-table :data="customerAnalysisData" border style="width: 100%">
            <el-table-column prop="customerName" label="客户名称" width="150" />
            <el-table-column prop="customerLevel" label="客户等级" width="100">
              <template #default="{ row }">
                <el-tag :type="getCustomerLevelType(row.customerLevel)">{{ row.customerLevel }}</el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="orderCount" label="订单数量" width="100" align="right" />
            <el-table-column prop="totalAmount" label="总消费金额" width="150" align="right">
              <template #default="{ row }">
                ¥{{ row.totalAmount.toFixed(2) }}
              </template>
            </el-table-column>
            <el-table-column prop="avgOrderAmount" label="平均订单金额" width="150" align="right">
              <template #default="{ row }">
                ¥{{ row.avgOrderAmount.toFixed(2) }}
              </template>
            </el-table-column>
            <el-table-column prop="lastOrderDate" label="最后下单日期" width="120" />
            <el-table-column prop="creditLimit" label="信用额度" width="120" align="right">
              <template #default="{ row }">
                ¥{{ row.creditLimit.toFixed(2) }}
              </template>
            </el-table-column>
            <el-table-column prop="creditUsed" label="已用额度" width="120" align="right">
              <template #default="{ row }">
                ¥{{ row.creditUsed.toFixed(2) }}
              </template>
            </el-table-column>
            <el-table-column label="信用使用率" width="120" align="right">
              <template #default="{ row }">
                <el-progress
                  :percentage="(row.creditUsed / row.creditLimit * 100)"
                  :color="getCreditColor(row.creditUsed / row.creditLimit)"
                  :stroke-width="8"
                />
              </template>
            </el-table-column>
          </el-table>
          <div class="pagination-wrapper">
            <el-pagination
              v-model:current-page="customerPagination.currentPage"
              v-model:page-size="customerPagination.pageSize"
              :page-sizes="[10, 20, 50, 100]"
              :total="customerPagination.total"
              layout="total, sizes, prev, pager, next, jumper"
              @size-change="handleCustomerPageSizeChange"
              @current-change="handleCustomerPageChange"
            />
          </div>
        </el-tab-pane>
        
        <!-- 商品分析 -->
        <el-tab-pane label="商品分析" name="products">
          <el-table :data="productAnalysisData" border style="width: 100%">
            <el-table-column prop="productCode" label="商品编码" width="120" />
            <el-table-column prop="productName" label="商品名称" width="200" />
            <el-table-column prop="category" label="分类" width="120" />
            <el-table-column prop="salesQuantity" label="销售数量" width="100" align="right" />
            <el-table-column prop="salesAmount" label="销售金额" width="120" align="right">
              <template #default="{ row }">
                ¥{{ row.salesAmount.toFixed(2) }}
              </template>
            </el-table-column>
            <el-table-column prop="profit" label="利润" width="120" align="right">
              <template #default="{ row }">
                <span :class="{ 'profit-positive': row.profit > 0, 'profit-negative': row.profit < 0 }">
                  ¥{{ row.profit.toFixed(2) }}
                </span>
              </template>
            </el-table-column>
            <el-table-column prop="profitRate" label="利润率" width="100" align="right">
              <template #default="{ row }">
                <span :class="{ 'profit-positive': row.profitRate > 0, 'profit-negative': row.profitRate < 0 }">
                  {{ (row.profitRate * 100).toFixed(1) }}%
                </span>
              </template>
            </el-table-column>
            <el-table-column prop="marketShare" label="市场占有率" width="120" align="right">
              <template #default="{ row }">
                {{ (row.marketShare * 100).toFixed(1) }}%
              </template>
            </el-table-column>
            <el-table-column prop="trend" label="趋势" width="100" align="center">
              <template #default="{ row }">
                <el-icon v-if="row.trend === 'up'" class="trend-up"><CaretTop /></el-icon>
                <el-icon v-else-if="row.trend === 'down'" class="trend-down"><CaretBottom /></el-icon>
                <el-icon v-else class="trend-stable"><Minus /></el-icon>
              </template>
            </el-table-column>
          </el-table>
          <div class="pagination-wrapper">
            <el-pagination
              v-model:current-page="productPagination.currentPage"
              v-model:page-size="productPagination.pageSize"
              :page-sizes="[10, 20, 50, 100]"
              :total="productPagination.total"
              layout="total, sizes, prev, pager, next, jumper"
              @size-change="handleProductPageSizeChange"
              @current-change="handleProductPageChange"
            />
          </div>
        </el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>

<script setup>
import { ref, reactive, onMounted, nextTick } from 'vue'
import { ElMessage } from 'element-plus'
import {
  TrendCharts,
  Document,
  User,
  Money,
  Search,
  Refresh,
  Download,
  CaretTop,
  CaretBottom,
  Minus
} from '@element-plus/icons-vue'
import * as echarts from 'echarts'

// 响应式数据
const activeTab = ref('sales')

// 筛选表单
const filterForm = reactive({
  dateRange: [],
  customerLevel: '',
  productCategory: ''
})

// 概览数据
const overviewData = reactive({
  totalSales: 12580000,
  totalOrders: 1256,
  totalCustomers: 328,
  totalProfit: 2516000
})

// 图表引用
const salesTrendChart = ref()
const customerDistributionChart = ref()
const productRankingChart = ref()
const profitAnalysisChart = ref()

// 分页数据
const salesPagination = reactive({
  currentPage: 1,
  pageSize: 10,
  total: 156
})

const customerPagination = reactive({
  currentPage: 1,
  pageSize: 10,
  total: 89
})

const productPagination = reactive({
  currentPage: 1,
  pageSize: 10,
  total: 234
})

// 模拟数据
const salesDetailData = ref([
  {
    date: '2024-01-15',
    customerName: '华东批发商城',
    customerLevel: 'VIP',
    productName: '苹果iPhone 15',
    quantity: 50,
    unitPrice: 6500,
    totalAmount: 325000,
    profit: 65000,
    profitRate: 0.2
  },
  {
    date: '2024-01-14',
    customerName: '南方电子批发',
    customerLevel: '一级',
    productName: '华为Mate 60',
    quantity: 30,
    unitPrice: 5800,
    totalAmount: 174000,
    profit: 34800,
    profitRate: 0.2
  },
  {
    date: '2024-01-13',
    customerName: '北京数码广场',
    customerLevel: '二级',
    productName: '小米14 Pro',
    quantity: 80,
    unitPrice: 4800,
    totalAmount: 384000,
    profit: 76800,
    profitRate: 0.2
  },
  {
    date: '2024-01-12',
    customerName: '深圳科技批发',
    customerLevel: 'VIP',
    productName: 'OPPO Find X7',
    quantity: 60,
    unitPrice: 4400,
    totalAmount: 264000,
    profit: 52800,
    profitRate: 0.2
  },
  {
    date: '2024-01-11',
    customerName: '广州手机批发',
    customerLevel: '三级',
    productName: 'vivo X100',
    quantity: 40,
    unitPrice: 3800,
    totalAmount: 152000,
    profit: 30400,
    profitRate: 0.2
  }
])

const customerAnalysisData = ref([
  {
    customerName: '华东批发商城',
    customerLevel: 'VIP',
    orderCount: 45,
    totalAmount: 2580000,
    avgOrderAmount: 57333,
    lastOrderDate: '2024-01-15',
    creditLimit: 5000000,
    creditUsed: 1800000
  },
  {
    customerName: '南方电子批发',
    customerLevel: '一级',
    orderCount: 32,
    totalAmount: 1890000,
    avgOrderAmount: 59063,
    lastOrderDate: '2024-01-14',
    creditLimit: 3000000,
    creditUsed: 1200000
  },
  {
    customerName: '北京数码广场',
    customerLevel: '二级',
    orderCount: 28,
    totalAmount: 1456000,
    avgOrderAmount: 52000,
    lastOrderDate: '2024-01-13',
    creditLimit: 2000000,
    creditUsed: 800000
  },
  {
    customerName: '深圳科技批发',
    customerLevel: 'VIP',
    orderCount: 38,
    totalAmount: 2234000,
    avgOrderAmount: 58789,
    lastOrderDate: '2024-01-12',
    creditLimit: 4000000,
    creditUsed: 1500000
  },
  {
    customerName: '广州手机批发',
    customerLevel: '三级',
    orderCount: 22,
    totalAmount: 986000,
    avgOrderAmount: 44818,
    lastOrderDate: '2024-01-11',
    creditLimit: 1500000,
    creditUsed: 600000
  }
])

const productAnalysisData = ref([
  {
    productCode: 'P001',
    productName: '苹果iPhone 15',
    category: '电子产品',
    salesQuantity: 1250,
    salesAmount: 8125000,
    profit: 1625000,
    profitRate: 0.2,
    marketShare: 0.35,
    trend: 'up'
  },
  {
    productCode: 'P002',
    productName: '华为Mate 60',
    category: '电子产品',
    salesQuantity: 980,
    salesAmount: 5684000,
    profit: 1136800,
    profitRate: 0.2,
    marketShare: 0.28,
    trend: 'up'
  },
  {
    productCode: 'P003',
    productName: '小米14 Pro',
    category: '电子产品',
    salesQuantity: 1580,
    salesAmount: 7584000,
    profit: 1516800,
    profitRate: 0.2,
    marketShare: 0.22,
    trend: 'stable'
  },
  {
    productCode: 'P004',
    productName: 'OPPO Find X7',
    category: '电子产品',
    salesQuantity: 760,
    salesAmount: 3344000,
    profit: 668800,
    profitRate: 0.2,
    marketShare: 0.18,
    trend: 'down'
  },
  {
    productCode: 'P005',
    productName: 'vivo X100',
    category: '电子产品',
    salesQuantity: 890,
    salesAmount: 3561000,
    profit: 712200,
    profitRate: 0.2,
    marketShare: 0.15,
    trend: 'up'
  }
])

// 方法
const formatNumber = (num) => {
  return (num / 10000).toFixed(1) + '万'
}

const getCustomerLevelType = (level) => {
  const typeMap = {
    'VIP': 'danger',
    '一级': 'warning',
    '二级': 'success',
    '三级': 'info',
    '普通': ''
  }
  return typeMap[level] || ''
}

const getCreditColor = (ratio) => {
  if (ratio < 0.5) return '#67c23a'
  if (ratio < 0.8) return '#e6a23c'
  return '#f56c6c'
}

const handleDateChange = () => {
  console.log('日期范围变更:', filterForm.dateRange)
}

const handleSearch = () => {
  console.log('搜索条件:', filterForm)
  ElMessage.success('查询成功')
}

const handleReset = () => {
  filterForm.dateRange = []
  filterForm.customerLevel = ''
  filterForm.productCategory = ''
  ElMessage.info('筛选条件已重置')
}

const handleExport = () => {
  ElMessage.success('报表导出成功')
}

const handleTabChange = (tabName) => {
  console.log('切换标签页:', tabName)
}

// 分页处理
const handleSalesPageSizeChange = (size) => {
  salesPagination.pageSize = size
  salesPagination.currentPage = 1
}

const handleSalesPageChange = (page) => {
  salesPagination.currentPage = page
}

const handleCustomerPageSizeChange = (size) => {
  customerPagination.pageSize = size
  customerPagination.currentPage = 1
}

const handleCustomerPageChange = (page) => {
  customerPagination.currentPage = page
}

const handleProductPageSizeChange = (size) => {
  productPagination.pageSize = size
  productPagination.currentPage = 1
}

const handleProductPageChange = (page) => {
  productPagination.currentPage = page
}

// 初始化图表
const initCharts = () => {
  // 销售趋势图
  const salesChart = echarts.init(salesTrendChart.value)
  const salesOption = {
    title: {
      text: '近30天销售趋势',
      left: 'center',
      textStyle: { fontSize: 14 }
    },
    tooltip: {
      trigger: 'axis',
      formatter: '{b}<br/>{a}: ¥{c}万'
    },
    xAxis: {
      type: 'category',
      data: ['1月1日', '1月5日', '1月10日', '1月15日', '1月20日', '1月25日', '1月30日']
    },
    yAxis: {
      type: 'value',
      name: '销售额(万元)'
    },
    series: [{
      name: '销售额',
      type: 'line',
      smooth: true,
      data: [120, 132, 101, 134, 90, 230, 210],
      itemStyle: { color: '#409EFF' },
      areaStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          { offset: 0, color: 'rgba(64, 158, 255, 0.3)' },
          { offset: 1, color: 'rgba(64, 158, 255, 0.1)' }
        ])
      }
    }]
  }
  salesChart.setOption(salesOption)

  // 客户分布图
  const customerChart = echarts.init(customerDistributionChart.value)
  const customerOption = {
    title: {
      text: '客户等级分布',
      left: 'center',
      textStyle: { fontSize: 14 }
    },
    tooltip: {
      trigger: 'item',
      formatter: '{a}<br/>{b}: {c} ({d}%)'
    },
    series: [{
      name: '客户等级',
      type: 'pie',
      radius: '60%',
      data: [
        { value: 45, name: 'VIP', itemStyle: { color: '#f56c6c' } },
        { value: 89, name: '一级', itemStyle: { color: '#e6a23c' } },
        { value: 123, name: '二级', itemStyle: { color: '#67c23a' } },
        { value: 67, name: '三级', itemStyle: { color: '#409eff' } },
        { value: 34, name: '普通', itemStyle: { color: '#909399' } }
      ],
      emphasis: {
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      }
    }]
  }
  customerChart.setOption(customerOption)

  // 商品销量排行
  const productChart = echarts.init(productRankingChart.value)
  const productOption = {
    title: {
      text: '商品销量排行TOP10',
      left: 'center',
      textStyle: { fontSize: 14 }
    },
    tooltip: {
      trigger: 'axis',
      axisPointer: { type: 'shadow' }
    },
    xAxis: {
      type: 'value'
    },
    yAxis: {
      type: 'category',
      data: ['iPhone 15', 'Mate 60', 'Mi 14 Pro', 'Find X7', 'X100', 'Galaxy S24', 'Pixel 8', 'OnePlus 12', 'Nothing Phone', 'Redmi K70']
    },
    series: [{
      name: '销量',
      type: 'bar',
      data: [1250, 980, 1580, 760, 890, 650, 540, 480, 420, 380],
      itemStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
          { offset: 0, color: '#67c23a' },
          { offset: 1, color: '#409eff' }
        ])
      }
    }]
  }
  productChart.setOption(productOption)

  // 利润分析
  const profitChart = echarts.init(profitAnalysisChart.value)
  const profitOption = {
    title: {
      text: '月度利润分析',
      left: 'center',
      textStyle: { fontSize: 14 }
    },
    tooltip: {
      trigger: 'axis'
    },
    legend: {
      data: ['销售额', '成本', '利润'],
      top: 30
    },
    xAxis: {
      type: 'category',
      data: ['1月', '2月', '3月', '4月', '5月', '6月']
    },
    yAxis: {
      type: 'value',
      name: '金额(万元)'
    },
    series: [
      {
        name: '销售额',
        type: 'bar',
        data: [1200, 1350, 1180, 1420, 1580, 1680],
        itemStyle: { color: '#409eff' }
      },
      {
        name: '成本',
        type: 'bar',
        data: [960, 1080, 944, 1136, 1264, 1344],
        itemStyle: { color: '#e6a23c' }
      },
      {
        name: '利润',
        type: 'line',
        data: [240, 270, 236, 284, 316, 336],
        itemStyle: { color: '#67c23a' },
        yAxisIndex: 0
      }
    ]
  }
  profitChart.setOption(profitOption)

  // 响应式处理
  window.addEventListener('resize', () => {
    salesChart.resize()
    customerChart.resize()
    productChart.resize()
    profitChart.resize()
  })
}

// 生命周期
onMounted(() => {
  nextTick(() => {
    initCharts()
  })
})
</script>

<style scoped>
.wholesale-statistics {
  padding: 20px;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h2 {
  margin: 0 0 8px 0;
  color: #303133;
  font-size: 24px;
  font-weight: 600;
}

.page-header p {
  margin: 0;
  color: #606266;
  font-size: 14px;
}

.statistics-overview {
  margin-bottom: 20px;
}

.stat-card {
  border: none;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}

.stat-item {
  display: flex;
  align-items: center;
  padding: 10px 0;
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  font-size: 24px;
  color: white;
}

.stat-icon.sales {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.stat-icon.orders {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-icon.customers {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.stat-icon.profit {
  background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.stat-content {
  flex: 1;
}

.stat-value {
  font-size: 28px;
  font-weight: bold;
  color: #303133;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 14px;
  color: #909399;
  margin-bottom: 4px;
}

.stat-change {
  font-size: 12px;
  font-weight: 500;
}

.stat-change.positive {
  color: #67c23a;
}

.stat-change.negative {
  color: #f56c6c;
}

.filter-section {
  margin-bottom: 20px;
}

.charts-section {
  margin-bottom: 20px;
}

.chart-container {
  width: 100%;
  height: 300px;
}

.table-section {
  margin-bottom: 20px;
}

.pagination-wrapper {
  margin-top: 20px;
  text-align: right;
}

.profit-positive {
  color: #67c23a;
  font-weight: 500;
}

.profit-negative {
  color: #f56c6c;
  font-weight: 500;
}

.trend-up {
  color: #67c23a;
  font-size: 18px;
}

.trend-down {
  color: #f56c6c;
  font-size: 18px;
}

.trend-stable {
  color: #909399;
  font-size: 18px;
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .chart-container {
    height: 250px;
  }
}

@media (max-width: 768px) {
  .wholesale-statistics {
    padding: 10px;
  }
  
  .stat-value {
    font-size: 24px;
  }
  
  .stat-icon {
    width: 50px;
    height: 50px;
    font-size: 20px;
    margin-right: 12px;
  }
  
  .chart-container {
    height: 200px;
  }
  
  .pagination-wrapper {
    text-align: center;
  }
}
</style>